<?php
if(!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

/*
 *照片墙
 *@author 王春林
 */
class photo extends MY_Controller {
	function __construct() {
		parent::__construct();
		$this->load->helper('url');
		$this->load->model('photo_model');
	}
	
	function index() {
		//$data["userId"] = $_POST['userId'];
		$data["userId"] = 7;
		$datas['collects'] = $this->listCollectImg($data);
		$datas['friends'] = $this->listFriendsImg($data);
		$datas['uploads'] = $this->listUploadImg($data);
		$this->load->view("photo_wall",$datas);
	}
	
	//获取收藏的照片
	function listCollectImg($data) {
		//$data["userId"] = $_POST['userId'];
		$rs = $this->photo_model->listCollectImg($data);
		//$datas['collect'] = $rs;
		//$this->load->view("photo_wall",$datas);
		return $rs;
	}
	
	//获取好友近期照片
	function listFriendsImg($data) {
		//$data['userId'] = $_POST['userId'];
		$rs = $this->photo_model->listFriendsImg($data);
		//$datas['friends'] = $rs;
		//$this->load->view("photo_wall",$datas);
		return $rs;
	}
	
	//获取上传的照片
	function listUploadImg($data) {
		//$data['userId'] = $_POST['userId'];
		$rs = $this->photo_model->listUploadImg($data);
		//$datas['uploads'] = $rs;
		//$this->load->view("photo_wall",$datas);
		return $rs;
	}
	function previewImages($userId,$type='Friends'){
		
		$this->getHeader();
		$data['type']				= $type;
		$data['previewImageUrl']	= base_url("index.php/photo/getPreviewImages/$userId/$type/-1");
		$data['replayCommentsUrl']	= base_url("index.php/photo/getReplayComments/PreviewReplay");	
		$this->load->view("user/preview_images",$data);
		$this->load->view("footers/footer01");
	}
	function getPreviewImages($userId,$type='Friends',$beginNumber=-1,$pageSize=55){
		echo json_encode($this->photo_model->getPreviewImages(array('userId'=>$userId),$type,$beginNumber,$pageSize));
		
	}
	function getReplayComments($divType='Replay',$type='dynamic',$id){
		$this->load->library('code_parents');
		$divCode	= $this->code_parents->getReplayDivs($id,$type,$divType);
		echo $divCode;
	}
}

?>